import Vue from 'vue'
import mask from './loadingmask.vue'
const maskConstructor = Vue.extend(mask)
maskConstructor.prototype.close = function () {
    document.body.removeChild(this.$el)
}
maskConstructor.prototype.resize = function () {
    console.log(this.$el.getBoundingClientRect())
    this.$el.style.width = window.innerWidth + 'px'
    this.$el.style.height = window.innerHeight + 'px'
}

const maskInstance = function (options = {}) {
    console.log('created loadingMask')
    let maskoptions = {
        title: '下载中',
        background: 'rgba(0,0,0,0)',
        color: '#fff',
        antiClockwise: false,
        progress: true,
        full: false,
    }
    let maskEl = new maskConstructor({
        el: document.createElement('div')
    })

    Object.assign(maskoptions, options)
    maskEl.options = maskoptions
    maskEl.tipsArry = maskoptions.title.split('')
    document.body.appendChild(maskEl.$el)
    return maskEl
}
export default maskInstance